package com.jredu.controller.server;

import java.io.File;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RequestMapping("/flie")
public class FileController {

	@RequestMapping("/doUpload")
	public void doUpload(
			String desc,
			MultipartFile file,
			HttpServletRequest req) throws IllegalStateException, IOException{
		System.out.println("文件描述："+desc);
		//保存文件
		if(!file.isEmpty()){
			 String root=req.getSession().getServletContext().getRealPath("/");
			 root+="\\upload\\"+ file.getOriginalFilename();
			 file.transferTo(new File(root));
		}
	}
}
